#include "WOP_String_Entry.h"
#include "Command_Agent.h"
#include <iostream>
using namespace std;



WOP_String_Entry::WOP_String_Entry(string s,WOP_Entry* parent){//被程式unfold出來的(top = false)
	init(s,parent);
}
WOP_String_Entry::WOP_String_Entry(string s){//user手動檢視的 (top = true)
	init(s,NULL);
}

bool WOP_String_Entry::update(){	
	string value ;

	if(_updated)//如果已經更新，那就跳過
		return _changed;		
	Command_Agent* ca = Command_Agent::getInstance();
	assert(_name != "?");  // a wop with name "?" should not be updated. Check who call this to find bugs 
	std::string new_value = ca->getValue(_name);//向CommandAgent要求更新數值
	if (new_value != _value) {
		_value = new_value ;
		_changed = true;
	}
	_updated = true ;
	return _updated ;
}